package com.youdianstar.app.common.base

import androidx.lifecycle.*


/**
 * File: IBaseViewModel
 * Author: 82149 Create: 2021/9/18 18:17
 * Changes (from 2021/9/18)
 * --------------------------------------------------
 * description:
 * ---------------------------------------------------
 *
 */
interface IBaseViewModel : LifecycleEventObserver {
    override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
        when(event){
            Lifecycle.Event.ON_CREATE-> onCreate()
            Lifecycle.Event.ON_START-> onStart()
            Lifecycle.Event.ON_RESUME-> onResume()
            Lifecycle.Event.ON_PAUSE-> onPause()
            Lifecycle.Event.ON_STOP-> onStop()
            Lifecycle.Event.ON_DESTROY-> onDestroy()
            else -> onAny(source,event)
        }
    }

    fun onAny(owner: LifecycleOwner, event: Lifecycle.Event)

    fun onCreate()

    fun onStart()

    fun onResume()

    fun onPause()

    fun onStop()

    fun onDestroy()

}